If the datasource of the subreport is a PC
Set CRXTables = CRXSubreport.Database.Tables
Set CRXTable = CRXTables.Item(1)
CRXTable.SetLogOnInfo <ODBC_DSN>, <databasename>, <userid>, <password>
If the datasource of the subreport is an active data source (ex. DAO, RDO, ADO, CDO, etc.), and the report is connecting using the active data driver (P2SMON.DLL), then you can use code similar to the following:
Set CRXTables = CRXSubreport.Database.Tables
Set CRXTable = CRXTables.Item(1)
CRXTable.SetDataSource rs, 3
There are many ways that you can access a subreport, and change the database location for a subreport. The above examples are simplified and generic so that they can be used and altered to accommodate an application with any report.
Each OLEDB provider requires a specific connection string. The following sample connection strings are for use in the "Connection" input box of the "ADO and OLE DB" option on the "Select Data Source" dialog box for the Active Data report expert:
Provider=Microsoft.Jet.OLEDB.3.51;Data Source=c:\Access\Northwind.mdb
Note: At this time, it is not possible to use secured Access databases in the Crystal Report expert.
Provider=SQLOLEDB;SERVER=SName;DATABASE=DBName; UID=MyID; PWD=MyPWD
Provider=SQLOLEDB;Server=TechTest;Database=Pubs;UID=Admin;PWD=sa
Provider=MSDASQL;DSN=MyDSN;UID=MyUID;PWD=MyPassword
Provider=MSDASQL;DSN=Xtreme Sample Database;UID=Admin;PWD=Password
For non
Xtreme Sample Database
Note: If it is OLE DB that is being used as the provider for ODBC, select the first option of the "Select Data Source" dialog box ("ODBC(ADO)") which uses that specific provider by default.
Provider=MSDAORA;Password=;User ID=;Data Source=
Provider=MSDAORA;Password=MyPassword;User ID=Admin;Data Source=MyOracleServer
Note: It will probably be necessary to re
If your reports connect to secure Microsoft Access sessions, you must provide session information at runtime using the SetSessionInfo method of the DatabaseTable object. This method accepts a user ID and password that are passed to the Access session to provide a connection to the database.
Session information must be added to your code using the SetSessionInfo method, even if you specified session information at design time. Session information specified at design time is not stored with the Report Designer Component.
Assuming all tables in your report are from the same secured Access database, you can use code similar to the following to set the Access session information:
Dim CRXReport As New CrystalReport1 Dim CRXTable as CRAXDRT.DatabaseTable For Each CRXTable In CRXReport.Database.Tables CRXTable.SetSessionInfo "user", "password" Next
If your report connects to a secure data source that requires log on information, you will not be able to log off of the data source until the Report object has been closed or has gone out of scope. Keep in mind that if you assign the Report object to the ReportSource property of the CRViewer object in the Crystal Reports Report Viewer, the Report object cannot be closed until you assign a new value to the Report Viewer or close the CRViewer object. Thus, you will not be able to log off of a secure data source until the report is no longer displayed in the Report Viewer.
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |